
import { BrowserWindow } from 'electron';
let mainWindow: BrowserWindow | null = null;
export function initHandler(win: BrowserWindow) {
    mainWindow = win;
}
export function dispatchCommand(command, socket, payload, clientInfo) {
    
    switch (command) {
        case 0x01:
            //处理不同的业务
            const response="命令1的处理结果"
            clientInfo.sendMsg = payload.toString("utf8");
            clientInfo.receiveMsg = response;
            socket.write(response);
            break;
        case 0x02:
            const response1="命令2的处理结果"
            clientInfo.sendMsg = payload.toString("utf8");;
            clientInfo.receiveMsg = response1;
            socket.write(response1);
            break;
        case 0x03:
            const response2="命令3的处理结果"
            clientInfo.sendMsg = payload.toString("utf8");;
            clientInfo.receiveMsg = response2;
            socket.write(response2);
            break;
        default:
            console.log("其他命令");
            clientInfo.sendMsg = command+payload.toString("utf8");;
            clientInfo.receiveMsg = "无效";
            socket.write("无效");
            break;
    }
 

}



